package com.zx1316.javasimpledoudizhu;

import com.zx1316.javasimpledoudizhu.client.ui.ClientController;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;

import java.io.IOException;

public class DDZApplication extends Application {
    //S黑桃 H红桃 C梅花 D方块
    public static final String[] INIT_CARD = new String[]{
            "JB", "JS", "S2", "H2", "C2", "D2", "SA", "HA", "CA", "DA", "SK", "HK", "CK", "DK", "SQ", "HQ", "CQ", "DQ",
            "SJ", "HJ", "CJ", "DJ", "S10", "H10", "C10", "D10", "S9", "H9", "C9", "D9", "S8", "H8", "C8", "D8", "S7", "H7",
            "C7", "D7", "S6", "H6", "C6", "D6", "S5", "H5", "C5", "D5", "S4", "H4", "C4", "D4", "S3", "H3", "C3", "D3"};

    public static void main(String[] args) {
        launch();
    }

    @Override
    public void start(Stage stage) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(DDZApplication.class.getResource("game-view.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        ClientController controller = fxmlLoader.getController();
        stage.setTitle("简单斗地主");
        stage.setScene(scene);
        stage.setResizable(false);
        stage.getIcons().add(new Image(Main.class.getResource("icon.png").openStream()));
        stage.show();
        stage.setOnCloseRequest(windowEvent -> {
            try {
                controller.onDisconnectClick();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });
    }
}
